#!/usr/bin/env node

const Koa = require('koa');
const log = console.log;
const logger = require('koa-logger');
const app = new Koa();
app.listen(8080);

app.use(logger());

app.use((ctx, next) => { 
    if(ctx.method == 'GET' && ctx.path == '/auhtors/') {
        log('查询漫画书作者列表');
        ctx.body = '查询成功';
    }
    if(ctx.method == 'GET' && /\/auhtors\/\w+/.test(ctx.path)) {
        log('查询漫画书作者 by name');
        ctx.body = '查询成功';
    }
    if(ctx.method == 'POST' && ctx.path == '/auhtors/') {
        log('添加漫画书作者');
        ctx.body = '添加成功';
    }
    if(ctx.method == 'PUT' && /\/auhtors\/\d+/.test(ctx.path)) {
        log('修改漫画书作者');
        ctx.body = '修改成功';
    }
    if(ctx.method == 'DELETE' && /\/auhtors\/\d+/.test(ctx.path)) {
        log('删除漫画书作者');
        ctx.body = '删除成功';
    }
});

